class Solution {
public:
    int tribonacci(int n) {
        vector<int> dp = { 0,1,1 };
        if (n <= 2) return dp[n];
        for (int i = 2; i < n; i++)
        {
            dp.push_back(dp[i] + dp[i - 1] + dp[i - 2]);
        }
        return dp.back();
    }
};